#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;
    while (n--)
    {
        int a, b, c;
        cin >> a >> b >> c;
        int min;
        int sum = 0;
        if (a > b)
        {
            if (b > c)
            {
                min = c;
            }
            else
            {
                min = b;
            }
        }
        else  // a < b
        {
            if (c < a)
            {
                min = c;
            }
            else
            {
                min = a;
            }
        }
        bool flag = false;
        if (a != 0 && b != 0 && c != 0)
            flag = true;
        sum += min * 2;
        a -= min; b -= min; c -= min;

        if (a != 0)
        {
            sum += a / 2;
        }

        if (c != 0)
        {
            sum += c / 2;
        }
        if (b != 0)
        {
            sum += b / 2;
        }
        if (flag == true && (a % 2 == 1 || c % 2 == 1))
            sum += 1;
        cout << sum << endl;
    }
    return 0;
}